#include <stdio.h>
#include <malloc.h>
#include "oes.h"

int main(){
    int res;
    unsigned char *puchSealListData = NULL;
    unsigned char *puchSealData = NULL;
    int puchSealListDataLen;
    int puchSealDataLen;
    int i;

    // 获取印章名称
    res = OSE_GetSealList(puchSealListData, &puchSealListDataLen);
    if (res != OES_OK){
        exit(-1);
    }
    puchSealListData = (unsigned char *) calloc(sizeof(unsigned char), puchSealListDataLen);
    res = OSE_GetSealList(puchSealListData, &puchSealListDataLen);
    if (res != OES_OK){
        exit(-1);
    }
    // 获取印章长度
    res = OES_GetSeal(puchSealListData, puchSealListDataLen, NULL, &puchSealDataLen);
    printf(">> [0x%08x] OES_GetSeal Data size: %d\n", res, puchSealDataLen);
    if (res != OES_OK){
        exit(-1);
    }
    puchSealData = (unsigned char *) calloc(sizeof(unsigned char), puchSealDataLen);
    res = OES_GetSeal(puchSealListData, puchSealListDataLen, puchSealData, &puchSealDataLen);
    printf(">> [0x%08x] OES_GetSeal Data:\n", res);
    if (res != OES_OK){
        exit(-1);
    }
    for ( i = 0; i < puchSealDataLen; ++i) {
        printf("%02X", puchSealData[i]);
    }
    printf("\n");
    
    free(puchSealListData);
    free(puchSealData);
}